package org.cheetahworkflow.designer.figure;

import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.MarginBorder;
import org.eclipse.draw2d.RoundedRectangle;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Display;

public class ModuleRectangleFigure extends RoundedRectangle {
	
	private static final Color COLOR_SEQUENCE_NODE = new Color(Display.getCurrent(), 0xB9, 0x64, 0xD4);

    private Label label;

    public ModuleRectangleFigure() {
        init();
    }
    
    private void init() {
    	label = new Label();
        add(label);
        label.setBorder(new MarginBorder(3, 5, 3, 5));
        setOpaque(true);
        setBackgroundColor(COLOR_SEQUENCE_NODE);
        setForegroundColor(ColorConstants.black);
        setCornerDimensions(new Dimension(12, 12));
    }

    public String getCaption() {
        return label.getText();
    }

    public Rectangle getTextBounds() {
        return label.getTextBounds();
    }

    public void setCaption(String caption) {
        label.setText(caption);
        this.repaint();
    }
    
    public void setBounds(Rectangle rect) {
        super.setBounds(rect);
        label.setBounds(rect);
    }
}